package com.swp.oa.sys.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.swp.oa.sys.dto.page.EasyuiDataGridJson;
import com.swp.oa.sys.service.IAuditService;
import com.swp.oa.sys.util.Pager;


@Controller
@RequestMapping("/audit")
public class AuditController {
	
	@Autowired
	private IAuditService auditService;
	//返回日志列表页面
	@RequestMapping("/Index")
	public String logIndex()
	{
		return "/Audit/Index";
	}
	
	
	@RequestMapping("/getLogList")
	@ResponseBody
	public EasyuiDataGridJson getLogList(int page, int rows, HttpServletRequest request)
	{
		String userName=request.getParameter("userName");
		String content = request.getParameter("content");
		String operationTimeStart =request.getParameter("operationTimeStart");
		String operationTimeEnd = request.getParameter("operationTimeEnd");
		System.out.println("userName :" + userName);
		System.out.println("content :" + content);
		System.out.println("operationTimeStart :" + operationTimeStart);
		System.out.println("operationTimeEnd :" + operationTimeEnd);
		System.out.println("page: " + page);
		System.out.println("rows: " + rows);
		EasyuiDataGridJson json = new EasyuiDataGridJson();
		Pager pager = auditService.getLogList(page, rows, userName, content, operationTimeStart, operationTimeEnd);
		if(pager != null){
			json.setRows(pager.getRows());
			json.setTotal(pager.getTotalCount());			
		}
		return json;
	}
}
